package com.ruoyi.transaction.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.common.entity.TransactionEntity.YZMProductComments;
import com.ruoyi.transaction.service.IYZMProductCommentsService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 商品评价Controller
 * 
 * @author yzm
 * @date 2025-08-07
 */
@RestController
@RequestMapping("/YZMcomments")
public class YZMProductCommentsController extends BaseController
{
    @Autowired
    private IYZMProductCommentsService yZMProductCommentsService;

    /**
     * 查询商品评价列表
     */
    @RequiresPermissions("transaction:YZMcomments:list")
    @GetMapping("/list")
    public TableDataInfo list(YZMProductComments yZMProductComments)
    {
        startPage();
        List<YZMProductComments> list = yZMProductCommentsService.selectYZMProductCommentsList(yZMProductComments);
        return getDataTable(list);
    }

    /**
     * 导出商品评价列表
     */
    @RequiresPermissions("transaction:YZMcomments:export")
    @Log(title = "商品评价", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, YZMProductComments yZMProductComments)
    {
        List<YZMProductComments> list = yZMProductCommentsService.selectYZMProductCommentsList(yZMProductComments);
        ExcelUtil<YZMProductComments> util = new ExcelUtil<YZMProductComments>(YZMProductComments.class);
        util.exportExcel(response, list, "商品评价数据");
    }

    /**
     * 获取商品评价详细信息
     */
    @RequiresPermissions("transaction:YZMcomments:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(yZMProductCommentsService.selectYZMProductCommentsById(id));
    }

    /**
     * 新增商品评价
     */
    @RequiresPermissions("transaction:YZMcomments:add")
    @Log(title = "商品评价", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YZMProductComments yZMProductComments)
    {
        return toAjax(yZMProductCommentsService.insertYZMProductComments(yZMProductComments));
    }

    /**
     * 修改商品评价
     */
    @RequiresPermissions("transaction:YZMcomments:edit")
    @Log(title = "商品评价", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YZMProductComments yZMProductComments)
    {
        return toAjax(yZMProductCommentsService.updateYZMProductComments(yZMProductComments));
    }

    /**
     * 删除商品评价
     */
    @RequiresPermissions("transaction:YZMcomments:remove")
    @Log(title = "商品评价", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(yZMProductCommentsService.deleteYZMProductCommentsByIds(ids));
    }
}
